<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/view/console/common/css.html"){}	%>

 <title></title>
 </head>
 <body>
 <div class="zq-form">
 <form name="wnMachineTool_form"  id="wnMachineTool_form" class="form-horizontal" style="margin-bottom: 70px;">
   <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">机具名称</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="name" id="name" class="form-control" check-type="required" value='${wnMachineTool.name!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">购入时间</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="buyTime" id="buyTime" class="layui-input" check-type="required" value='${wnMachineTool.buyTime!,"yyyy-MM-dd HH:mm:ss"}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">品牌</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="brand" id="brand" class="form-control" check-type="required" value='${wnMachineTool.brand!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">幅宽</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="breadth" id="breadth" class="form-control" check-type="required" value='${wnMachineTool.breadth!}' >
 </div>
  </div>
 <div class="form-group">
 <label class="control-label col-sm-2 col-xs-2">机具类型</label>
 <div class="col-sm-6 col-xs-6">
 	<select class="form-control" id="type"
 		name="type" check-type="required">
 </select>
 </div>
 </div>
 <div class="form-group">
 <label class="control-label col-sm-2 col-xs-2">所属农场</label>
 <div class="col-sm-6 col-xs-6">
 	<select class="form-control" id="farmId"
 		name="farmId" check-type="required">
 </select>
 </div>
 </div>
 
   <input type='hidden' name='id' id='id' value='${wnMachineTool.id!}'><input type='hidden' name='common_token' id='common_token' value='${common_token!}'>
 </form>
  <nav class="navbar navbar-default navbar-fixed-bottom" style="text-align: right">
    <a href="#" class="btn btn-success" style="margin:10px"  onclick='saveZqForm()'>保存 </a>
  </nav>
 </div>
 <% include("/view/console/common/js.html"){} 	%>
 <script type='text/javascript' src='/view/console/wnMachineTool/wnMachineToolForm.js'></script>
 <script>

     layui.use(['layer','laydate'], function(){
         var laydate= layui.laydate;
         //常规用法
         laydate.render({
             elem: '#buyTime'
         });
     });
     $(function($) {
         $("#farmId").change(function () {
             localStorage.setItem("machineAdd_farmId",$("#farmId").val());
         })
      /*开启表单验证*/
         $("#wnMachineTool_form").validation();
         componentSelectInit(
             {
                 ctxPath:'',
                 tableName:"sys_dictionary",
                 showValueField:"name",
                 valueField:"value",
                 selectId:"type"  ,
                 where:" where code ='machine_tool_type' "
             }
             ,function(){
                 $("#type").val('${wnMachineTool.type!}');
             });
         componentSelectInit(
             {
                 ctxPath:'',
                 tableName:"wn_farm",
                 showValueField:"name",
                 valueField:"id",
                 selectId:"farmId"  ,
                 where:""
             }
             ,function(){
                 $("#farmId").val('${wnMachineTool.farmId!}');
             });

     });
     /*保存*/
     function saveZqForm(){
         if ($("#wnMachineTool_form").valid() == false) {
             return false;
         }
         var formObject=new Object();
         formObject.name=$('#name').val()==''?null:$('#name').val();
         formObject.buyTime=$('#buyTime').val()==''?null:$('#buyTime').val();
         formObject.brand=$('#brand').val()==''?null:$('#brand').val();
         formObject.breadth=$('#breadth').val()==''?null:$('#breadth').val();
         formObject.type=$('#type').val()==''?null:$('#type').val();
         formObject.farmId=$('#farmId').val()==''?null:$('#farmId').val();
         formObject.id=$('#id').val()==''?null:$('#id').val();

         var formObjectJson = JSON.stringify(formObject);
         zqPost("/console/wn_machine_tool/save",
             {
                 formObjectJson :formObjectJson,
                 machineId:"${machineId!}",
                 common_token :$("#common_token").val()
             }, function(data) {
                 layer.alert(data.message, {skin: 'layui-layer-molv',closeBtn: 0 }, function(){
                     parent.$("#wnMachineTool").bootstrapTable("refresh");
                     parent.layer.closeAll();
                 });

             });
     }

 </script>
 </body>
